package com.yihaodian.search.query.converter;

import org.apache.lucene.search.FieldCacheRangeFilter;
import org.apache.lucene.search.Filter;

import com.yihaodian.api.search.filter.RangeFilter;

public class RangeFilterConvert {
	public static Filter convert(com.yihaodian.api.search.filter.Filter filter){
		if (filter == null) {
			return null;
		}
		
		Filter result = null;
		if (filter instanceof RangeFilter) {
			RangeFilter rangeFilter = (RangeFilter)filter;
			result = FieldCacheRangeFilter.newIntRange(rangeFilter.getField(), 
					rangeFilter.getLowerVal(), rangeFilter.getUpperVal(), 
					rangeFilter.isIncludeLower(), rangeFilter.isIncludeUpper());
		}
		
		return result;
	}
}
